home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Palettes / MiscArrowButtonPalette / MiscArrowButton.subproj / MiscArrowButton.m < prev    next >
Encoding:
Text File  |  1995-04-12  |  2.7 KB  |  117 lines

  1. // Copyright (C) 1995 Robert Todd Thomas
  2. // Use is governed by the MiscKit license
  3.  
  4. /******************************************************************
  5.  * CLASS:        MiscArrowButton
  6.  *
  7.  *    See the header for more information on this class.
  8.  *
  9.  * This object is included in the MiscKit by permission from the author
  10.  * and its use is governed by the MiscKit license, found in the file
  11.  * "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  12.  * for a list of all applicable permissions and restrictions.
  13.  *******************************************************************/
  14.  
  15. #import "MiscArrowButtonCell.h"
  16. #import "MiscArrowButton.h"
  17.  
  18. static id  myStoredCellClass;
  19.  
  20.  
  21. @implementation MiscArrowButton
  22.  
  23. + initialize
  24. {
  25.     myStoredCellClass = [MiscArrowButtonCell class];
  26.     return self;
  27. }
  28.  
  29.  
  30.  
  31. + setCellClass: classId
  32. {
  33.     myStoredCellClass = classId;
  34.     return self;
  35. }
  36.  
  37.  
  38.  
  39. - init
  40. {
  41.   NXRect frameRect;
  42.  
  43.     // create some frame since none was specified
  44.       
  45.       NXSetRect (&frameRect, 10.0, 10.0, 125.0, 25.0);
  46.     
  47.     return [self initFrame: (const NXRect *)&frameRect title: "Left" 
  48.             altTitle: "Right" tag: 0 target: nil action: NULL key: 0 
  49.             enabled: YES];
  50. }
  51.  
  52.  
  53.  
  54. - initFrame: (const NXRect *)frameRect
  55. {
  56.     return [self initFrame: frameRect title: "Left" altTitle: "Right"
  57.             tag: 0 target: nil action: NULL key: 0 enabled: YES];
  58. }
  59.  
  60.  
  61.  
  62. // The button class's designated initializer for text buttons, which
  63. // now should just call mine (see next method).
  64.  
  65. - initFrame:(const NXRect *)frameRect title:(const char *)aString
  66.         tag:(int)anInt target:anObject action:(SEL)aSelector
  67.         key:(unsigned short)charCode enabled:(BOOL)flag
  68. {
  69.     return [self initFrame: frameRect title: aString altTitle: "Right"
  70.             tag: anInt target: anObject action: aSelector 
  71.             key: charCode enabled: flag];
  72. }
  73.  
  74.  
  75.  
  76. // The designated initializer that merely adds the capability to set
  77. // the altTitle (text on the right side of the arrow) while initializing
  78. // the button.
  79.  
  80. - initFrame:(const NXRect *)frameRect title:(const char *)aString
  81.         altTitle: (const char *)altString tag:(int)anInt 
  82.         target:anObject action:(SEL)aSelector
  83.         key:(unsigned short)charCode enabled:(BOOL)flag
  84. {
  85.     [super initFrame: frameRect title: aString tag: anInt target: anObject
  86.             action: aSelector key: charCode enabled: flag];
  87.  
  88.     [self setAltTitle: altString];
  89.     [self setType: NX_TOGGLE];
  90.     [ [self setCell: [ [myStoredCellClass alloc] init] ] free];
  91.     
  92.     return self;
  93. }
  94.  
  95.  
  96.  
  97. // Used to set arrow alignment. (In previous versions, setAlignment was used
  98. // but I realized that I also needed those methods). Sorry for any 
  99. // inconvenience.
  100.  
  101. - setArrowAlignment: (int)alignment
  102. {
  103.     [ [self cell] setArrowAlignment: alignment];
  104.     return self;
  105. }
  106.  
  107.  
  108.  
  109. - (int)arrowAlignment
  110. {
  111.     return [ [self cell] arrowAlignment];
  112. }
  113.  
  114. @end
  115.  
  116.  
  117.